-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metrics API scaler to support parsing numbers in quotes as well as quantities. #1668
Conversation
306226f
to
c5de4c2
Compare
Quantity is returned as a member of ExternalMetricValue so there should be no impact. Signed-off-by: Joe Shearn <joseph.shearn@sainsburys.co.uk>
@turbaszek would you mind looking at this? |
pkg/scalers/metrics_api_scaler.go
Outdated
r := gjson.GetBytes(body, valueLocation) | ||
if r.Type == gjson.String { | ||
q, err := resource.ParseQuantity(r.String()) | ||
if err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will be returned if the err!=nil
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would revert to the original behaviour and return "valueLocation must point to value of type number got: string"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've improved the error handling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look reasonable to me, just one question
@devjoes could you please open another PR with documentation of this feature? in content/docs/2.2 https://github.com/kedacore/keda-docs |
Signed-off-by: Joe Shearn <joseph.shearn@sainsburys.co.uk>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Quantities can now be parsed from a metrics API response. Lots of metrics APIs return Quantity types which get marshalled to strings (KEDA itself actually has this behaviour).
ExternalMetricValue.Value is already a Quantity so there should be no impact on the wider codebase.
Checklist
Fixes #1667